<template>
	<view v-if="visible" class="custom-modal-mask">
		<view class="custom-modal" style="padding: 0;">
			<view style="padding: 48rpx 36rpx 24rpx 36rpx;">
				<view class="custom-modal-title" style="font-size:40rpx;margin-bottom:24rpx;text-align:center;">
					用户协议和隐私政策</view>
				<view class="custom-modal-content"
					style="font-size:30rpx;color:#222;line-height:1.7;text-align:left;margin-bottom:0;">
					请你务必审慎阅读、充分理解"用户协议"和"隐私政策"各条款，包括但不限于：为了更好的向你提供服务，我们需要收集你的设备标识、操作日志等信息用于分析、优化应用性能。你可阅读
					<text class="link-text" @click="onServiceAgreement">《用户协议》</text>
					和
					<text class="link-text" @click="onPrivacyPolicy">《隐私政策》</text>
					了解详细信息。若你同意，请点击下方按钮开始接受我们的服务。
				</view>
			</view>
			<view style="height:2rpx;background:#eee;margin:48rpx 0 0 0;"></view>
			<view class="custom-modal-actions" style="gap:0;margin:0;padding:0;">
				<navigator target="quickApp" open-type="exit" class="custom-modal-btn left-btn">拒绝</navigator>
				<text class="custom-modal-btn right-btn"
					style="flex:1;border-radius:0 0 32rpx 0;border-left:2rpx solid #eee;border-top:none;"
					@click="onPrivacyConfirm">同意</text>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	name: 'PrivacyModal',
	props: {
		visible: {
			type: Boolean,
			default: false
		}
	},
	methods: {
		onServiceAgreement() {
			uni.navigateTo({
				url: '/pages/xieyi',
			});
		},
		onPrivacyPolicy() {
			uni.navigateTo({
				url: '/pages/yinsi',
			});
		},
		onPrivacyConfirm() {
			this.$emit('privacy-confirm');
		}
	}
}
</script>

<style scoped>
.custom-modal-mask {
	position: fixed;
	z-index: 9999;
	left: 0;
	top: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.25);
	display: flex;
	align-items: center;
	justify-content: center;
}

.custom-modal {
	width: 80vw;
	max-width: 680rpx;
	background: #fff;
	border-radius: 32rpx;
	box-shadow: 0 8rpx 40rpx rgba(0, 0, 0, 0.08);
	padding: 48rpx 40rpx 24rpx 40rpx;
	text-align: center;
}

.custom-modal-title {
	font-size: 36rpx;
	font-weight: 600;
	margin-bottom: 32rpx;
	color: #222;
}

.custom-modal-content {
	font-size: 30rpx;
	color: #444;
	margin-bottom: 56rpx;
	line-height: 1.6;
	text-align: left;
}

.custom-modal-actions {
	display: flex;
	margin: 0;
	padding: 0;
	justify-content: center;
	background: #f8f9fa;
	border-radius: 0 0 32rpx 32rpx;
	overflow: hidden;
}

.custom-modal-btn {
	flex: 1;
	height: 90rpx;
	font-size: 32rpx;
	font-weight: 600;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: all 0.3s ease;
	margin: 0;
	box-sizing: border-box;
	position: relative;
	overflow: hidden;
}

.custom-modal-btn::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.05);
	opacity: 0;
	transition: opacity 0.3s ease;
}

.custom-modal-btn:active::before {
	opacity: 1;
}

.left-btn {
	display: flex;
	flex: 1;
	background: #ffffff;
	color: #666666;
	border: none;
	/* border-right: 2rpx solid #e5e5e5; */
}

.left-btn:active {
	background: #f5f5f5;
	color: #333333;
}

.right-btn {
	background: linear-gradient(135deg, #8b4513 0%, #a0522d 100%);
	color: #ffffff;
	border: none;
	box-shadow: 0 4rpx 16rpx rgba(139, 69, 19, 0.3);
}

.right-btn:active {
	background: linear-gradient(135deg, #a0522d 0%, #8b4513 100%);
	transform: translateY(2rpx);
	box-shadow: 0 2rpx 8rpx rgba(139, 69, 19, 0.4);
}

.link-text {
	color: #3478f6;
	cursor: pointer;
	text-decoration: underline;
}
</style>